/*
 * Dummy tester to start a Chisel project.
 *
 * Author: Martin Schoeberl (martin@jopdesign.com)
 * 
 */

package MYMAC

import chisel3._
import chiseltest._
import org.scalatest.flatspec.AnyFlatSpec

class MACTester extends AnyFlatSpec with ChiselScalatestTester {

  "MAC" should "work" in {
    test(new MYMAC(5,8)) { dut =>
      dut.reset.poke(true.B)
      dut.clock.step()
      dut.reset.poke(false.B)
      dut.clock.step()
      dut.io.macIO.switchw.poke(false.B)
      dut.io.macIO.weightIn.poke(4.S)
      dut.io.macIO.weightWe.poke(true.B)
      dut.io.macIO.weightTag.poke((5-1).U)
      //dut.io.macIO.switchw.poke(false.B)
      //dut.io.macIO.weightWe.poke(false.B)
      println("Result is: " + dut.io.macIO.outDelay.peek().toString)
      println("Input  is: " + dut.io.macIO.dataDelay.peek().toString)
      println("---------------------------------------------")
      dut.clock.step()
      dut.io.macIO.weightWe.poke(false.B)
      dut.io.macIO.dataIn.poke(3.S)
      dut.io.macIO.accIn.poke(0.S)
      dut.clock.step()
      println("Result is: " + dut.io.macIO.outDelay.peek().toString)
      println("Input  is: " + dut.io.macIO.dataDelay.peek().toString)
      println("---------------------------------------------")

      dut.io.macIO.dataIn.poke(4.S)
      dut.io.macIO.accIn.poke(2.S)
      dut.clock.step()
      println("Result is: " + dut.io.macIO.outDelay.peek().toString)
      println("Input  is: " + dut.io.macIO.dataDelay.peek().toString)

      dut.io.macIO.dataIn.poke(5.S)
      dut.io.macIO.accIn.poke(10.S)
      println("---------------------------------------------")
      dut.clock.step()
      println("Result2 is: " + dut.io.macIO.outDelay.peek().toString)
      println("Input2  is: " + dut.io.macIO.dataDelay.peek().toString)
      println("---------------------------------------------")
    }
  }
}
